package activator;

import library.service.LibraryService;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import service.factory.MixedBookFactory;

public class Activator implements BundleActivator {

	private ServiceRegistration libServiceReg;

	// --- BundleActivator interface implementation ---------------------------
	public void start(BundleContext bundleContext) throws Exception {

		// register library service
		libServiceReg = bundleContext.registerService(
				LibraryService.class.getName(), new MixedBookFactory(), null);

		System.out
				.println("REGISTRATOR ServiceFactory: start() method");
	}

	public void stop(BundleContext context) throws Exception {
		// libraryServiceRegistration clean up
		if (libServiceReg != null) {
			libServiceReg.unregister();
			libServiceReg = null;

			System.out
					.println("REGISTRATOR ServiceFactory: stop() method");
		}
	}

}
